﻿using OrderSystem.Templet;
using System;

namespace OrderSystem
{
    public partial class InputBox : FormTemplet
    {
        private static string s_inputString = null;

        public InputBox()
        {
            InitializeComponent();
        }

        private InputBox(string sCaption, string sInputData) : this()
        {
            this.Text = sCaption;
            this.txtInput.Text = sInputData;
            InputBox.s_inputString = null;
        }

        private InputBox(string sCaption, string sInputData, char cPasswrodChar) : this()
        {
            this.txtInput.PasswordChar = cPasswrodChar;
            this.Text = sCaption;
            this.txtInput.Text = sInputData;
            InputBox.s_inputString = null;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            InputBox.s_inputString = this.txtInput.Text;
            base.Close();
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            InputBox.s_inputString = null;
            base.Close();
        }

        public static string ShowBox(string sCaption, string sInputData)
        {
            InputBox inputBox = new InputBox(sCaption, sInputData);
            inputBox.ShowDialog();
            return InputBox.s_inputString;
        }

        public static string ShowBox(string sCaption, string sInputData, char cPasswrodChar)
        {
            InputBox inputBox = new InputBox(sCaption, sInputData, cPasswrodChar);
            inputBox.ShowDialog();
            return InputBox.s_inputString;
        }
    }
}
